package com.qys.common.config;

import com.qys.common.config.intercepors.LoginIntercepor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * Created by fangc on 2019-10-20 00:48
 */
@Configuration
public class MyWebConfig extends WebMvcConfigurationSupport {
    // 配置静态资源
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/" );
    }

    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截的请求，并排除几个不拦截的请求
        InterceptorRegistration registration = registry.addInterceptor(new LoginIntercepor());
        registration.addPathPatterns("/**");
        registration.excludePathPatterns("/", "/check" , "/err" ,"/static/**" , "/css/**");
    }

}
